﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using University.Workshop.Presenters.OutflowMoney.Search;

namespace University.Workshop.Presentation.OutflowMoney
{
    /// <summary>
    /// Interaction logic for SearchOutFlow.xaml
    /// </summary>
    public partial class SearchOutFlow : Page, ISearchOutflowView
    {
        PresenterSearchOutflow pSearchOutflow;
        public SearchOutFlow()
        {
            InitializeComponent();
            pSearchOutflow = new PresenterSearchOutflow(this);
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            App.Current.MainWindow.Title = "Buscar Egresos";
        }

        public void NavigateToRead(Model.Expense expense)
        { 
            NavigationService.Navigate(new Expenses.Read(expense));
        }

        public void NavigateToRead(Model.WaterPurchase expense)
        {
            NavigationService.Navigate(new WaterPurchase.PageReadView(expense));
        }
        #region Fields
        public DateTime? InitialDate
        {
            get 
            {
                return initialDateDpk.SelectedDate;
            }
        }

        public DateTime? EndDate
        {
            get 
            {
                return endDateDpk.SelectedDate;
            }
        }

        public decimal totalMoney
        {
            set 
            {
                totalMoneyTxt.Text = value.ToString();
            }
        }

        public ICollection<Model.ExpenseControl> ExpensesFinded
        {
            set
            {
                expensesFindeddDgv.ItemsSource = null;
                expensesFindeddDgv.ItemsSource = value;
            }
        }
        #endregion

        #region Buttons Actions
        private void SearchBtn_Click(object sender, RoutedEventArgs e)
        {
            pSearchOutflow.SearchOutflow();
        }

        private void ShowOtbDataBtn_Click(object sender, RoutedEventArgs e)
        {
            pSearchOutflow.SendToRead(((Model.ExpenseControl)expensesFindeddDgv.SelectedItem));
        }
        #endregion

        #region ErrorMessage
        public void NotifyErrorMessage(string message)
        {
            MessageBox.Show(App.Current.MainWindow, message, "Error!!!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.RightAlign);
        }
        #endregion

    }
}
